import { _decorator, Component, Node, Collider2D, IPhysics2DContact } from "cc";
const { ccclass, property } = _decorator;
import { BaseReward } from "../BaseReward";
import { BaseBullet } from "../BaseBullet";
import { BulletStateMachine } from "../Bullet/BulletStateMachine";
import { BulletEnum } from "../Enum/BulletEnum";
import DataManager from "../Runtime/DataManager";
import { MoreBulletState } from "../Bullet/MoreBulletState";
@ccclass("MoreShoot")
export class MoreShoot extends BaseReward {
  // 添加触发标志位
  private isTriggered = false;
  // 重写父类方法
  protected onBeginContact(
    selfCollider: Collider2D,
    otherCollider: Collider2D,
    contact: IPhysics2DContact | null
  ) {
    if (this.isTriggered) return;
    this.isTriggered = true;
    console.log("MoreShootonBeginContact");
    if (MoreBulletState.bulletNumber < 3) {
      MoreBulletState.bulletNumber += 1;
    } else {
      MoreBulletState.bulletNumber = 3;
    }
    DataManager.Instance.player
      .getComponent(BulletStateMachine)
      .changeState(BulletEnum.More);
  }
}
